GBML manual / Sets

set_has

True if value is currently a member of target, false otherwise.

Syntax

set_has(target, value) -> bool

Arguments

NameType
targetset
valueelement

Returns

bool

Description

true if value is currently a member of target, false otherwise. This is the entire point of reaching for a set<T> instead of a list<T> - checking membership is fast no matter how many values target already holds.

Example

/// @type {set<int>}
var visited = [5];
var has5 = set_has(visited, 5); // true
var has6 = set_has(visited, 6); // false
A real capture - the set holding 5, and HAS 5? answering YESA real capture - the set holding 5, and HAS 5? answering YES
A real capture - the set holding 5, and HAS 5? answering YES
The same set, unchanged - HAS 6? answering NO, since 6 was never addedThe same set, unchanged - HAS 6? answering NO, since 6 was never added
The same set, unchanged - HAS 6? answering NO, since 6 was never added

On the GBA

Just the hash set's contains() - O(1) average.

See also: set_containsset_addset_removeset_lengthData containers